﻿<UserControl x:Class="StockholmsStad.Windows.UI.Modules.Ceremony.Controls.CeremonyPreviousDetailsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converters="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Converters;assembly=StockholmsStad.Windows.UI.Infrastructure"
    MinWidth="300">
    <UserControl.Resources>
        <converters:CeremonyTypeToBoolConverter x:Key="ceremonyTypeConverter" />
        <converters:EnumToBooleanConverter x:Key="enumToBoolConverter" />
        
        <!--Define the template for column to contain a CheckBox control-->
        <DataTemplate x:Key="SelectionCell">
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding Path=IsCompleted, Mode=TwoWay}" Content="Genomförd"/>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    
    <GroupBox Header="Tidigare" Margin="5,5,5,5" Padding="5,10,5,5">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <ListView x:Name="listViewCeremonies" ItemsSource="{Binding}" Grid.Row="0" 
                      ItemContainerStyle="{DynamicResource ListViewItemStyleNoInteraction}"
                      MaxHeight="300" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> 
                <ListView.View>
                    <GridView ColumnHeaderContainerStyle="{DynamicResource GridViewColumnHeaderStyle1}" AllowsColumnReorder="False">
                        <GridView.Columns>
                            <GridViewColumn Header="Tid">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding StartEndTime}" VerticalAlignment="Center">
                                            <TextBlock.Style>
                                                <Style>
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding CeremonyType, Converter={StaticResource ceremonyTypeConverter}}" Value="False">
                                                            <Setter Property="TextBlock.Visibility" Value="Collapsed" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBlock.Style>
                                        </TextBlock>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Par">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Path=Person1.FullName}" />
                                            <TextBlock Text=" / " />
                                            <TextBlock Text="{Binding Path=Person2.FullName}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Förrättare">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Path=Minister.FullName}" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Status" CellTemplate="{StaticResource SelectionCell}">
                            </GridViewColumn>
                            <GridViewColumn Header="Skriv ut">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="Skriv ut" DataContext="{Binding}" Click="btnPrint_Click" Height="20" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>                          
                        </GridView.Columns>
                    </GridView>
                </ListView.View>
            </ListView>
            
            <StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Center">
                <Button x:Name="SaveButton" Content="Spara" Margin="10,0,10,0" Click="SaveButton_Click" />
            </StackPanel>

        </Grid>
        
    </GroupBox>
</UserControl>
